package com.bookstore.dao.imp;

import com.bookstore.bean.Trade;
import com.bookstore.dao.TradeDao;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * Created by Admin on 2016/8/27.
 */
public class TradeDaoImp extends BaseDao<Trade> implements TradeDao {
    @Override
    public void insert(Trade trade) {
        String sql="insert into trade (userId,tradeTime) values (?,?)";
        long tradeId= insert(sql,trade.getUserId(),trade.getTradeTime());
        trade.setTradeId((int) tradeId);
    }

    @Override
    public Set<Trade> getTradesWithUserId(Integer userId) {
        String sql="select tradeId,userId,tradeTime from trade where userId=? order by tradeTime desc ";
        return new LinkedHashSet<>(getForList(sql,userId));
    }
}
